import {getGoodsList} from "../../request/api"
const state={
    goodsList:[],
    page:1,
    size:5
}
const mutations={
    changeGoods(state,arr){
        state.goodsList=arr;
    }
}
const actions={
    goodsActions(context,arr){
        let params={
            cateid:arr[0],
            page:context.state.page,
            size:context.state.size,
            type:arr[1]
        }
        getGoodsList(params).then(res=>{
           if(res.code===200){
               console.log(res);
               context.commit("changeGoods",res.list.goodData)
           }
        })
    }
    
  
}
const getters={
    goodsList(state){
        return state.goodsList;
    }
}

export default {
    state,
    mutations,
    actions,
    getters,
    namespaced:true
}